import 'package:flutter_test/flutter_test.dart';
import 'package:lib_common/lib_common.dart';

void main() {
  group("测试字符匹配验证", () {
    test("测试字符长度:长度短", () {
      var regExp = RegExp(r"^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$");
      bool result = StringUtils.match(regExp, "a2345");
      expect(result, true);
    });
    test("测试字符长度:长度长", () {
      var regExp = RegExp(r"^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$");
      bool result = StringUtils.match(regExp, "a1234556789098765421·");
      expect(result, true);
    });
    test("测试字符规则:纯数字", () {
      var regExp = RegExp(r"^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$");
      bool result = StringUtils.match(regExp, "123456");
      expect(result, true);
    });
    test("测试字符规则:纯字母", () {
      var regExp = RegExp(r"^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$");
      bool result = StringUtils.match(regExp, "abcdef");
      expect(result, true);
    });
    test("测试字符规则:纯符号", () {
      var regExp = RegExp(r"^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$");
      bool result = StringUtils.match(regExp, "+_><:?");
      expect(result, true);
    });
    test("测试字符规则:包含数字，字母", () {
      var regExp = RegExp(r"^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$");
      bool result = StringUtils.match(regExp, "a12345");
      expect(result, true);
    });
    test("测试字符规则:包含数字，字符", () {
      var regExp = RegExp(r"^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$");
      bool result = StringUtils.match(regExp, "_12345");
      expect(result, true);
    });
    test("测试字符规则:包含字母，字符", () {
      var regExp = RegExp(r"^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$");
      bool result = StringUtils.match(regExp, "_ghijk");
      expect(result, true);
    });
    test("测试字符规则:包含数字，字母，字符", () {
      var regExp = RegExp(r"^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,20}$");
      bool result = StringUtils.match(regExp, "_123ghijk");
      expect(result, true);
    });
  });
}
